home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 367 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.0 KB

  1. From: kanze@gabi.gabi-soft.fr (J. Kanze)
  2. Message-ID: <KANZE.96Feb9155337@gabi.gabi-soft.fr>
  3. X-Original-Date: 09 Feb 1996 14:53:37 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 09 Feb 96 15:40:02 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Return-Path: <daemon@meeker.UCAR.EDU>
  8. Newsgroups: comp.std.c++
  9. Subject: Re: auto_ptr again
  10. Organization: GABI Software, Sarl.
  11. References: <4ebhn5$lgt@bmtlh10.bnr.ca> <4eucnc$hr9@hermes.synopsys.com>
  12.     <9602051159.AA19131@lts.sel.alcatel.de> <4fbapm$lbk@hermes.synopsys.com>
  13. In-Reply-To: jbuck@Synopsys.COM's message of 07 Feb 1996 15:00:06 PST
  14. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  15.     iQBFAgUBMRtq3uEDnX0m9pzZAQFnmQF/QoEso0icbPxHXA14EPVMQ2LdeTuRpvYf
  16.     9ParQP7gh/KtBplZliiWVCnNd9aGU3Bh
  17.     =lPSF
  18.  
  19. In article <4fbapm$lbk@hermes.synopsys.com> jbuck@Synopsys.COM (Joe
  20. Buck) writes:
  21.  
  22. > I wrote:
  23. > >|> Anyone who writes a class in which X(X&) or X(const X&) does not have the
  24.  
  25. > >|> semantics of a copy operation is doing something wrong (e.g. auto_ptr in
  26. > >|> the draft standard is broken).
  27. > James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> writes:
  28. > >I wouldn't go quite that far.  X(X&) is a particular form of copy,
  29. > >which modifies the copied object.  If it is programmed in such a way
  30. > >that the number of intermittent copies is meaningless (as is the case
  31. > >in auto_ptr), then it is perfectly valid.
  32. > You're not really disagreeing with me, James.  X(X&) is a reasonable
  33. > thing to do in some cases, and the source object will then be modified,
  34. > but if this operation does not look like a copy that leaves the
  35. > functioning of the argument object mostly unaltered, the user of the class
  36. > is going to have problems and surprises.  Many uses of X(X&) just modify
  37. > private members to keep some sort of internal record, e.g. how many copies
  38. > there are and connections between them.
  39.  
  40. That's what mutable is for.
  41.  
  42. I have no problems with the desired semantics for auto_ptr, for example.
  43. Copy and assignment modify the copied/assigned from object completely.
  44. They render it invalid.  You can hardly say that this is leaving the
  45. object `mostly unaltered'.  However, the number of intermediate objects
  46. is irrelevant; the function is transitive.  The `copy' is actually more
  47. of a `move'.
  48.  
  49. Perhaps one of the reasons I want auto_ptr so badly in the standard is
  50. that this is *not* something you would want to do in an arbitrary user
  51. class, anymore than you would want to redefine left shift to mean input.
  52. It because valid because it *is* part of the `standard' language;
  53. everyone knows and uses it in this way.
  54. -- 
  55. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  56. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  57. Conseils, itudes et rialisations en logiciel orienti objet --
  58.               -- A la recherche d'une activiti dans une region francophone
  59. ---
  60. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  61.   Contact address: std-c++-request@ncar.ucar.edu.  Moderation policy:
  62.   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
  63.